#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int ret = 0;
	while (a >= 2 || (a == 1 && b == 9)) {
		a -= 1;
		b -= 9;
		if (b < 0) {
			a--;
			b += 10;
		}
		ret++;
	}
	cout << ret;
	return 0;
}